package pl.un4giv3n.mightvsmagic.action.clan;

import javax.persistence.EntityManager;

import pl.un4giv3n.mightvsmagic.entity.Clan;

public class ShowOtherClanPageAction extends ClanAction{

	private static final long serialVersionUID = 1L;
	private Long clanId;

	@Override
	public String execute() {
		EntityManager entityManager = getEntityManager();
		user = getSessionUser(entityManager);
		if (user == null) {
			addActionError("Zaloguj się");
			entityManager.close();
			return LOGIN;
		}
		clan = entityManager.find(Clan.class, clanId);
		if(clan == null){
			entityManager.close();
			addActionError("Wybrany klan nie istnieje");
			return INPUT;
		}
		entityManager.close();
		return SUCCESS;
	}

	public Long getClanId() {
		return clanId;
	}

	public void setClanId(Long clanId) {
		this.clanId = clanId;
	}
}
